﻿// -------------------------------------------------------------------------
//    @FileName         :    NFCityWorldObjectFunc.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-09-17
//    @Email			:    445267987@qq.com
//    @Module           :    NFCityWorldObjectFunc
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "NFCityPlayerViewExt.h"
#include "proto_cs.pb.h"
#include "NFComm/NFObjCommon/NFObject.h"
#include "NFComm/NFShmStl/NFShmVector.h"

class NFCityWorldObject;
class NFCityPlayer;

class NFICityWorldObjectFunc
{
public:
    virtual ~NFICityWorldObjectFunc()
    {
    }

    virtual int DoFunc(NFCityWorldObject* pWorldObject) = 0;

    virtual bool IsBreakIterate() { return false; }
};

class NFMakeNpcView : public NFICityWorldObjectFunc
{
public:
    NFMakeNpcView(NFCityPlayer* pPlayer, proto_ff::Proto_CSRsp* pCSRsp);

    ~NFMakeNpcView() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;
    int Send();

private:
    int m_iEnterViewCnt;
    NFCityPlayer* m_pPlayer;
    proto_ff::Proto_CSRsp* m_pCSRsp;
};


class NFMakePlayerView : public NFICityWorldObjectFunc
{
public:
    NFMakePlayerView(NFCityPlayer* pPlayer, proto_ff::Proto_CSRsp* pCSRsp);

    ~NFMakePlayerView() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;
    int Send();

private:
    int m_iEnterViewCnt;
    NFCityPlayer* m_pPlayer;
    proto_ff::Proto_CSRsp* m_pCSRsp;

    NFShmVector<NFCityPlayer*, MAX_VIEW_PLAYER_NUM> m_apPlayer;
};

class NFOtherEnterView : public NFICityWorldObjectFunc
{
public:
    NFOtherEnterView(NFCityPlayer* pPlayer);

    ~NFOtherEnterView() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;
    int Send();

private:
    int m_iEnterViewCnt;
    NFCityPlayer* m_pPlayer;
    proto_ff::Proto_CSRsp m_oCSRsp;
};

class NFEnterViewOther : public NFICityWorldObjectFunc
{
public:
    NFEnterViewOther(NFCityWorldObject* pWorldObject);

    virtual ~NFEnterViewOther()
    {
    }

    virtual int DoFunc(NFCityWorldObject* pWorldObject);

private:
    NFCityWorldObject* m_pActiveObject;
    proto_ff::Proto_CSRsp m_oCSRsp;

    bool m_bIsAction;
    proto_ff::Proto_CSRsp m_oCSActionRsp;
};

class NFRefreshViewOther : public NFICityWorldObjectFunc
{
public:
    NFRefreshViewOther(NFCityWorldObject* pWorldObject);

    ~NFRefreshViewOther() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;

private:
    NFCityWorldObject* m_pActiveObject;
    proto_ff::Proto_CSRsp m_oCSRsp;

    bool m_bIsAction;
    proto_ff::Proto_CSRsp m_oCSActionRsp;
};

class NFOtherLeaveView : public NFICityWorldObjectFunc
{
public:
    NFOtherLeaveView(NFCityPlayer* pPlayer) : m_iLeaveViewCnt(0), m_pPlayer(pPlayer)
    {
        m_oCSRsp.mutable_map_leave_view_ntf()->set_reason(proto_ff::LEAVE_VIEW_OUT);
    }

    ~NFOtherLeaveView() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;
    int Send();

private:
    int m_iLeaveViewCnt;
    NFCityPlayer* m_pPlayer;
    proto_ff::Proto_CSRsp m_oCSRsp;
};

class NFLeaveViewOther : public NFICityWorldObjectFunc
{
public:
    NFLeaveViewOther(NFCityWorldObject* pWorldObject);

    ~NFLeaveViewOther() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;

private:
    NFCityWorldObject* m_pActiveObject;
    proto_ff::Proto_CSRsp m_oCSRsp;
};

class NFWorldObjectNotifyMessage : public NFICityWorldObjectFunc
{
public:
    NFWorldObjectNotifyMessage(NFCityWorldObject* pActiveObject, int iCmd, const google::protobuf::Message* pMessage) : m_pActiveObject(pActiveObject), m_iCmd(iCmd), m_pCSRsp(pMessage)
    {
    }

    ~NFWorldObjectNotifyMessage() override
    {
    }

    int DoFunc(NFCityWorldObject* pWorldObject) override;
    int Send();

private:
    NFCityWorldObject* m_pActiveObject;
    int m_iCmd;
    const google::protobuf::Message* m_pCSRsp;
};
